#include "RAM_Disk.h"

unsigned char RDISK[RAM_DISK_CAP];
//unsigned char RDISK[16];

void RAM_Disk_Init(void)
{
	int i;
	for(i=0;i<RAM_DISK_CAP;i++)
		RDISK[i] = 0;
}

void RAM_Disk_SectorRead(u8* pBuffer, u32 ReadAddr, u16 NumSectorToRead)
{
	int i;
	int rd_byte_cnt,rd_byte_end_addr;
	
	rd_byte_cnt = NumSectorToRead * RAM_DISK_SECTOR_SIZE;
	rd_byte_end_addr = ReadAddr + rd_byte_cnt;
	
	for(i = ReadAddr ; i < rd_byte_end_addr ; i++)
		pBuffer[i] = RDISK[i];
	
	return;
}

void RAM_Disk_SectorWrite(u8* pBuffer, u32 WriteAddr, u16 NumSectorToWrite)
{
	int i;
	int wr_byte_cnt,wr_byte_end_addr;
	
	wr_byte_cnt = NumSectorToWrite * RAM_DISK_SECTOR_SIZE;
	wr_byte_end_addr = WriteAddr + wr_byte_cnt;
	
	for(i = WriteAddr ; i < wr_byte_end_addr ; i++)
		RDISK[i] = pBuffer[i];
	
	return;
}

